<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta http-equiv="pragram" content="no-cache">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>[title]</title>
    <link href="/Public/Home/css/style.css" rel="stylesheet" type="text/css">
    <link href="/Public/Home/css/iconfont.css" rel="stylesheet" type="text/css">
    <script src="/Public/Home/js/jquery-1.11.1.min.js"></script>
    <script src="/Public/Home/js/publicjquery.js"></script>
    <script src="/Public/Home/js/layer/layer.js" ></script>
    <script src="/Public/Home/js/common.js" ></script>
    <script src="/Public/Home/js/ajaxfileupload.js" ></script>
</head>
<body onselectstart="return false">
<div class="main FromUpToDown" >
    <div class="content" style="position: relative">
        <div class="head-content">
            <div class="head-title">
                <span><?php echo ACTION_NAME == 'edit' ? '修改' : '添加';?>短信模板</span>
            </div>
        </div>
        <form action='' id="form" >
            <input type="hidden" name="id" value="<?php echo ($info['id']); ?>">
            <div class="form-content">
                <div class="form">
                    <div class="form-left">用户</div>
                    <div class="form-right">
                        <select class="form-input-small" name="user_id" >
                            <?php if(is_array($user)): foreach($user as $key=>$vo): ?><option value="<?php echo ($vo['id']); ?>"><?php echo ($vo['name']); ?></option><?php endforeach; endif; ?>
                        </select>
                    </div>
                </div>
                <div class="form">
                    <div class="form-left">语音总量</div>
                    <div class="form-right">
                        <input class="form-input-small" type="text" name='capacity'  value="<?php echo ($info['capacity']); ?>" placeholder="语音总量"  />
                    </div>
                </div>
                <div class="form-operate">
                    <button type='button' id="save"  class="form-button color-bg-green">保存</button>
                    <button type='button' onclick="history.go(-1)" class="form-button color-bg-grey">返回</button>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="main-foot">Copyright  2013-2015 WeiGouTong.com. All Rights Reserved.  苏ICP备09098830号</div>
<script>
    $("#save").click(function(){

        if($("input[name='user_id']").val() == ''){
            layer.tips('请选择用户！', 'input[name="user_id"]', {tips: [2, 'red'], time: 1000});
            return;
        }
        if($("input[name='capacity']").val() == ''){
            layer.tips('请输入短信容量！', 'input[name="capacity"]', {tips: [2, 'red'], time: 1000});
            return;
        }
        $("#save").attr('disabled',true);
        $.post(
                "<?php echo U('save');?>",
                $("#form").serialize(),
                function(res){
                    if(res.status == 1){
                        layer.tips(res.info, '#save', {tips: [2, 'green'], time: 1000});
                        setTimeout("location.href = document.referrer",1000);
                    }else{
                        $("#save").attr('disabled',true);
                        layer.tips(res.info, '#save', {tips: [2, 'red'], time: 1000});
                    }
                }
        );
    });
</script>
</body>
</html>